<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <div th:replace="common/common :: copy"></div>
    <title>添加课程表 - 课程表管理 - H-ui.admin v3.1</title>
    <meta name="keywords" content="H-ui.admin v3.1,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
    <meta name="description" content="H-ui.admin v3.1，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
</head>
<body>
<article class="page-container">
    <form class="form form-horizontal" id="form-admin-add">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>课程表ID：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="" placeholder="" id="ID" name="ID">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">
                <span class="c-red">*</span>课程名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
				<select  name="courseNO" class="select valid" aria-required="true" aria-invalid="false">
					<option th:each="c : ${courseList}" th:value="${c.courseID}" th:text="${c.courseName}">全部类型</option>
				</select>
				</span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">
                <span class="c-red">*</span>班级名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
				<select  name="classNO" class="select valid" aria-required="true" aria-invalid="false">
					<option th:each="c : ${classList}" th:value="${c.classNO}" th:text="${c.classNO}">全部类型</option>
				</select>
				</span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">
                <span class="c-red">*</span>教师名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
				<select  name="teacherID" class="select valid" aria-required="true" aria-invalid="false">
					<option th:each="t : ${teacherList}" th:value="${t.teacherID}" th:text="${t.name}">全部类型</option>
				</select>
				</span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>学年：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
				<select  name="schoolYear" class="select valid" aria-required="true" aria-invalid="false" >
					<option th:each="i:${#numbers.sequence(2000, 2099)}" th:selected="${#dates.format(new java.util.Date().getTime(), 'yyyy')}==${i}" th:text="${i}" th:value="${i}">全部类型</option>
				</select>
				</span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>学期：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
				<select  name="term" class="select valid" aria-required="true" aria-invalid="false" >
					<option value="0">上学期</option>
					<option value="1">下学期</option>
				</select>
				</span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>开始周：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="" placeholder="" id="startWeek" name="startWeek">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>结束周：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="" placeholder="" id="endWeek" name="endWeek">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>星期几：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="" placeholder="" id="weekday" name="weekday">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>第几节：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="" placeholder="" id="section" name="section">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">
                <span class="c-red">*</span>地点：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
				<select  name="locationNo" class="select valid" aria-required="true" aria-invalid="false">
					<option th:each="l : ${locationList}" th:value="${l.locationNo}" th:text="${l.locationName}">全部类型</option>
				</select>
				</span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">
                <span class="c-red">*</span>教室：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
				<select  name="classRoomNO" class="select valid" aria-required="true" aria-invalid="false">
					<option th:each="l : ${classRoomList}" th:value="${l.classRoomNO}" th:text="${l.classRoomNO}">全部类型</option>
				</select>
				</span>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input id="submit" class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>


<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" th:src="@{/lib/jquery.validation/1.14.0/jquery.validate.js}"></script>
<script type="text/javascript" th:src="@{/lib/jquery.validation/1.14.0/validate-methods.js}"></script>
<script type="text/javascript" th:src="@{/lib/jquery.validation/1.14.0/messages_zh.js}"></script>
<script type="text/javascript" th:inline="javascript">
    var ctxPath = [[@{/}]];
    $(function () {
            $('.skin-minimal input').iCheck({
                checkboxClass: 'icheckbox-blue',
                radioClass: 'iradio-blue',
                increaseArea: '20%'
            });
        $.validator.addMethod(  //添加自定义验证函数
            "validateID",       //自定义验证函数的名称
            function(value,element,params){
                var deferred = $.Deferred();//创建一个延迟对象
                $.ajax({        //发送Ajax请求
                    type:"GET",
                    async:false,
                    url:ctxPath+"curriculum/isAvailableID",
                    dataType:"json",    //数据类型为json,发回的数据已自动解析
                    data:{
                        ID:function(){return $("#ID").val();},
                    },
                    success:function(data){
                        if (data.code==100) {
                            console.log(100)
                            deferred.resolve();
                        } else {
                            deferred.reject();
                        }
                    }
                });
                return deferred.state() == "resolved" ? true : false;
            },
            "ID重复，请重新输入！！！"
        );
            $("#form-admin-add").validate({
                rules: {
                    ID: {
                        required: true,
                        minlength: 1,
                        maxlength: 16,
                        validateID:true
                    },
                    courseNO: {
                        required: true,
                    },classNO: {
                        required: true,
                    },teacherID: {
                        required: true,
                    },schoolYear: {
                        required: true,
                    },term: {
                        required: true,
                    },startWeek: {
                        required: true,
                    },endWeek: {
                        required: true,
                    },section: {
                        required: true,
                    },locationNo: {
                        required: true,
                    },classRoomNO: {
                        required: true,
                    },weekday: {
                        required: true,
                    }
                },
                onkeyup: false,
                focusCleanup: true,
                success: "valid",
                submitHandler: function (form) {
                    $(form).ajaxSubmit({
                        type: 'post',
                        url: ctxPath + "curriculum/curriculumAdd",
                        success: function (data) {
                            console.log(data)
                            if (data.code == 100) {
                                layer.msg('添加成功!', {icon: 1, time: 1000});
                                setTimeout(function() {
                                    var index = parent.layer.getFrameIndex(window.name);
                                    window.parent.location.reload();
                                    parent.layer.close(index);
                                },2000)
                            }
                            if (data.code == 500) {
                                layer.msg('添加失败!', {icon: 2, time: 1000});
                            }
                        },
                        error: function (XmlHttpRequest, textStatus, errorThrown) {
                            layer.msg('error!', {icon: 1, time: 1000});
                        }
                    });
                }
            });
        })
</script>
</body>
</html>